package com.reggie.utils;

import java.util.Random;

/**
 * @Author 早睡蛋
 * @Date 2022/7/11 21:03:40
 * @Desc:验证码工具类
 */
public class CodeUtil {
    private static char[] codeLetter = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9'};

    /**
     * 生成验证码
     *
     * @return
     */
    public static String getCode() {
        Random random = new Random();
        String code = "";
        for (int i = 0; i < 6; i++) {
            String oneCode = String.valueOf(codeLetter[random.nextInt(codeLetter.length)]);
            code += oneCode;
        }
        return code;
    }
}
